package com.xxxx.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author Str
 * @Date 2021/9/27 22:50
 * @Description :
 */
//@Controller注解的类会自动添加到Spring上下文中
@Controller
//映射访问路径
@RequestMapping("/demo03")
public class HelloController {

    //映射访问路径
    @RequestMapping("/hello")
    public String hello(Model model){
        // 封装数据
        //Spring MVC会自动实例化一个Model对象用于向视图中传值
        model.addAttribute("msg","Hello Spring MVC");
        //返回视图位置
        return "hello";  // 会被视图解析器处理，找到hello.jsp
    }
}
